function paint(leader,total_op_num,FF)
%% 绘制全局最优解的甘特图
global  operation_time operation_machine  num_machine num_job;
[ZZ,~,Pvals,GG,VV]=fitness(leader,FF);
Pval1=Pvals{1,1};
figure(2);
for i=1:total_op_num
    mText=leader(total_op_num+i);%几号机器
    b=leader(i);%工序
    x1=Pval1(1,i);%各工序开始
    x2=Pval1(2,i); %各工序结束
    y1=mText-0.2;
    y2=mText+0.2;
    hold on; 
    fill([x1,x2,x2,x1],[y1,y1,y2,y2],[b/num_job,0.999,1/b]);%工件不同颜色不同1-1/b
    text((x1+x2)/2-0.2,mText,[num2str(b),'-',num2str(length(find(leader(1:i)==b)))]);
    text((x1+x2)/2,mText-0.3,num2str(leader(2*total_op_num+i)));  
    fill([0,0,0,0],[num_machine,num_machine,num_machine+1,num_machine+1],[0,0,0]);
    c=find(operation_machine{b}{length(find(leader(1:i)==b))}==mText);
    a=operation_time{b}{length(find(leader(1:i)==b))}(c);
    if (x2-x1)~=a
        disp('出错啦！');
        z=Pvall*x1;
    end
end
set(gca,'yTick',1:1:num_machine+1);
%text(0,num_machine+1,['  f=',num2str(ZZ),'         f1=',num2str(GG(1)),'         f2=',num2str(GG(2)),'        f3=',num2str(GG(3)),'         f4=',num2str(GG(4))]);
%text(0,num_machine+0.5,['    Makespan=',num2str(VV(1)),'      Total energy consumption=',num2str(VV(2)),'    Total work load=',num2str(VV(3)),'      Critical work load=',num2str(VV(4))]);
text(0,num_machine+0.5,['    Makespan=',num2str(VV(1)),'      Total energy consumption=',num2str(VV(2))]);
text(0,num_machine+1,['    Total work load=',num2str(VV(3)),'      Critical work load=',num2str(VV(4))]);
%title('Gantt chart of problem Mk01 for makespan');
xlabel('Time');
ylabel('Machine');
end
